<?php


function displayError($validationErrors,$var)
{

	$data = "";
	foreach ($validationErrors as $key => $value)
	{
		if ($key == $var)
		{
			$data[] = $value;
		}
	}
	
	if (!empty($data))
	{
		$ret = "<span><ul><li>";
		$ret .= implode("</li><li>",$data);
		$ret .= "</li></ul></span>";
		
		return $ret;
		
	}
}


if (empty($validationErrors)) $validationErrors['data'] = "none";





echo "<div class=\"\">";
echo $form->create();

echo "<table class=\"form\">";
echo "<tr>";

echo "<td colspan=\"3\"><h3>".__("Team's information")."</h3></td>";
echo "</tr><tr>";


echo "<td>".__("Name")."</td>";
echo "<td>";
echo "<input type=\"text\" name=\"data[Registration][Login]\" value=\"".@$data['Registration']['Login']."\" />";
echo "</td>";
echo "<td>".displayError($validationErrors,'Login')."</td>";
echo "</tr><tr>";


echo "<td>".__("Tag")."</td>";
echo "<td>";
echo "<input type=\"text\" name=\"data[Registration][Email]\" value=\"".@$data['Registration']['Email']."\" />";

echo "</td>";
echo "<td>".displayError($validationErrors,'Email')."</td>";
echo "</tr><tr>";


echo "<td>".__("Team's tag after or before player's name ?")."</td>";
echo "<td>";

$checked = "";
$checked2 = "";

if (!empty($data['Registration']['Team']) && $data['Registration']['Team'] == 1) $checked = "checked";
else if (!empty($data['Registration']['Team']) && $data['Registration']['Team'] == 2) $checked2 = "checked";

echo "<input type=\"radio\" name=\"data[Registration][Team]\" value=\"1\" $checked /> Before&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;";
echo "<input type=\"radio\" name=\"data[Registration][Team]\" value=\"2\" $checked2 /> After";
echo "</td>";
echo "<td>".displayError($validationErrors,'Team')."</td>";
echo "</tr><tr>";



echo "<td>".__("Country")."</td>";
echo "<td>";
//echo "<input type=\"text\" name=\"data[Registration][Nationality]\" value=\"".@$data['Registration']['Nationality']."\" />";

echo "<select name=\"data[Registration][Nationality]\">";

echo "<option value=\"\">-- SELECT --</option>";

$selected = "";
foreach($country as $tab)
{
	if (strtolower($tab['GeolocalisationCountry']['Iso']) == strtolower($data['Registration']['Nationality'])) $selected = "selected";
	else $selected = "";
	echo "<option value=\"".strtolower($tab['GeolocalisationCountry']['Iso'])."\" $selected>".$tab['GeolocalisationCountry']['PrintableName']."</option>";
}


echo "</select>";



echo "</td>";
echo "<td>".displayError($validationErrors,'Nationality')."</td>";
echo "</tr><tr>";




echo "<td colspan=\"3\"><h3>".__("Password")."</h3></td>";
echo "</tr><tr>";




echo "<td>".__("Password")."</td>";
echo "<td>";
echo "<input type=\"text\" name=\"data[Registration][Password]\" value=\"\" />";

echo "</td>";
echo "<td>".displayError($validationErrors,'Password')."</td>";
echo "</tr><tr>";



echo "<td>".__("Password (repeat)")."</td>";
echo "<td>";
echo "<input type=\"text\" name=\"data[Registration][Password2]\" value=\"\" />";
echo "</td>";
echo "<td>".displayError($validationErrors,'Password2')."</td>";
echo "</tr>";














echo "<td colspan=\"3\"><h3>".__("Confirmation")."</h3></td>";
echo "</tr><tr>";


/*
echo "<td colspan=\"3\"><h3>".__("Team")."</h3></td>";
echo "</tr><tr>";



echo "<td>".__("Name")."</td>";
echo "<td>";
//echo "<input type=\"text\" name=\"data[Registration][Nationality]\" value=\"".@$data['Registration']['Nationality']."\" />";

echo "<select name=\"data[Registration][Nationality]\">";

foreach($country as $tab)
{

	echo "<option value=\"".$tab['GeolocalisationCountry']['InternationalStandardizationOrganization']."\">".$tab['GeolocalisationCountry']['PrintableName']."</option>";
}


echo "</select>";



echo "</td>";
echo "<td>".displayError($validationErrors,'Nationality')."</td>";
echo "</tr><tr>";



echo "<td>".__("Password")."</td>";
echo "<td>";
echo "<input type=\"text\" name=\"data[Registration][Firstname]\" value=\"".@$data['Registration']['FirstName']."\" />";
echo "</td>";
echo "<td>".displayError($validationErrors,'FirstName')."</td>";
echo "</tr><tr>";

*/















echo "<td colspan=\"3\">";
echo $form->submit("Registration");
echo "</td>";
echo "</tr><tr>";



echo "</table>";

echo $form->end();

?>